import React, { FC } from 'react';
import { Button } from 'antd';
import './index.css';

export interface baseBtnListProps {
  btnList: string[];
  btnClickCallback?: (name: string) => void;
}

const BankBtnList: FC<baseBtnListProps> = (props) => {
  const { btnList, btnClickCallback } = props;

  const btnListView = () => {
    return btnList.map((k, i) => {
      if (k === '删除') {
        return <Button key={i} className='btn' type="primary" danger onClick={() => btnClickCallback && btnClickCallback(k)}>{k}</Button>
      } else if (k === '新增') {
        return <Button key={i} className='btn' onClick={() => btnClickCallback && btnClickCallback(k)}>{k}</Button>
      } else {
        return <Button key={i} className='btn' type='primary' onClick={() => btnClickCallback && btnClickCallback(k)}>{k}</Button>
      }
    })
  }

  return (<>{btnListView()}</>)
}

export { BankBtnList }